/**
 * 
 */
package org.swing.utility.system.cmd;

import org.swing.utility.system.flatform.SystemUtil;
import org.swing.utility.system.imp.ServiceController;

/**
 * @author lqnhu
 *
 */

public class ServiceControllerFactory {

	private static ServiceController serviceController;

	public static ServiceController getServiceController() throws Exception {
		synchronized (ServiceController.class) {
			if (serviceController == null) {
				if (SystemUtil.IS_WINDOWS) {
					serviceController = new WindowsServiceController();
				} else if (SystemUtil.IS_MAC_OS) {
					serviceController = new MacServiceController();
				} else if (SystemUtil.IS_UNIX) {
					serviceController = new LinuxServiceController();
				} else {
					throw new Exception(
							"Operating system must be Windows, Mac, or Unix/Linux.");
				}
			}

			return serviceController;
		}
	}

}
